home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Viewers / ACRViewer.1.3 / developer / OperatorExample / Threshold / ThreshOperator.m < prev   
Encoding:
Text File  |  1995-05-03  |  804 b   |  43 lines

  1.  
  2. #import "ThreshOperator.h"
  3.  
  4. @implementation ThreshOperator
  5.  
  6. - (const char*) operatorName
  7. {
  8.     return "Threshold";
  9. }
  10.  
  11. - openPanel
  12. {
  13.     [self loadInterface:"threshold.nib"];
  14.     return [super openPanel];
  15. }
  16.  
  17. - processImage:(unsigned short*) data 
  18.     withWidth:(int)width height:(int) height 
  19.     minValue:(unsigned short) minValue andMaxValue:(unsigned short) maxValue
  20. {
  21. unsigned int low= [threshForm intValueAt:0];
  22. unsigned int high= [threshForm intValueAt:1];
  23. unsigned int inValue= [threshForm intValueAt:2];
  24. unsigned int v;
  25. int i;
  26. int count = width*height;
  27.  
  28.     if (inValue == 0)
  29.         for (i= 0; i<count; i++){
  30.             v= data[i];
  31.             if (v < low || v>high) v= 0;
  32.             data[i]= v;
  33.         }
  34.     else 
  35.         for (i= 0; i<count; i++){
  36.             v= data[i];
  37.             if (v < low || v>high) v= 0; else v= (int)inValue;
  38.             data[i]= v;
  39.         }
  40.     return self;
  41. }
  42. @end
  43.